var Session = require("../../common/session.js");

Page({
    getUserInfo: function (e) {
        if (e.detail == undefined || e.detail.errMsg != 'getUserInfo:ok') {
            return;
        }
        wx.login({
            success: function (res) {
                var code = res.code;
                var data = {
                    code: code,
                    encryptedData: e.detail.encryptedData,
                    iv: e.detail.iv,
                    rawData: e.detail.rawData,
                }
                //返回微信用户信息
                // Session.userLogin(data)
                //     .then(() => {
                        wx.reLaunch({
                            url: '/pages/index/index',
                        })
                    // });
            },
            fail: function (err) {
                reject(err);
            }
        })
    },
    exitLogin: function () {
        wx.reLaunch({
            url: '/pages/authAndLogin/authAndLogin',
        })
        setTimeout(function () {
            wx.navigateBack({
                delta: 2
            })
        }, 500);
    }
})